*********************************
***  Trump paper - Figure 2
*** Created: 31/10/2020
*** Last updated: 21/05/2021
clear all
set scheme plottig
 

	local user = 1		/* user 1 = sergi, user 2 = Anja */

	if `user' == 1 {			// input relevant file path as per your computer

		global		main "/Users/aneundorf/Dropbox/Project_Populism/BA project/Analysis/Trump_Replication files/"
		global 		graphs 			"${main}Graphs/"
		global 		results			"${main}Results/"
	}

cd "${main}"
use "Data/US_data_recoded.dta", clear

global controls_all female age01 educ2 educ3 dom2 dom3 dom4 ethnic2 ethnic3 ethnic4 relig3 relig2

reg trump_vsbiden ib4.Group##c.unemp_prob $controls_all
margins, dydx(i.Group) at(unemp_prob=(1 2 3 4))
marginsplot, plot2opts(lc(none) mc(none)) plot3opts(lc(none) mc(none)) ci2opt(lc(none)) ci3opt(lc(none)) legend(off) yline(0) title("A. Trump vote by unemployment risk", size(large)) ytitle("Marginal effect of economic treatment", size(medlarge)) xlabel(, labsize(medsmall)) ylabel(-.5(.1).4, labsize(medsmall)) xtitle("Unemployment risk (1=very; 4=none)", size(medium)) name(vote_unemp, replace)

reg trump_vsbiden ib4.Group##c.income_linear $controls_all
margins, dydx(i.Group) at(income=(1(1)24))
marginsplot, plot2opts(lc(none) mc(none)) plot3opts(lc(none) mc(none)) ci2opt(lc(none)) ci3opt(lc(none)) legend(off) yline(0) title("B. Trump vote by income", size(large)) ytitle("Marginal effect of economic treatment", size(medlarge)) xlabel(, labsize(medsmall)) ylabel(-.5(.1).4, labsize(medsmall)) xtitle("Income (1= <$15,000; 24= $250,000+)", size(medium)) name(vote_inc, replace)

** Create graphs
graph combine vote_unemp vote_inc , row(1) graphregion(fcolor(white) lc(black)) xsize(8) ysize(5) 
graph save  "${graphs}Figure2.gph",  replace
graph export  "${graphs}Figure2.pdf", as(pdf) replace
